

/**
 * 创建entity Ellipsoid
 */
import Entity from '../Entity'

export default class Ellipsoid extends Entity {

  /**
   * 创建一个Ellipsoid实体对象
   * @param {*} positions
   * @param {*} options 
   */
  constructor(positions, options = {}) {
    super()
    this._positions = positions
    this._radius = new Cesium.Cartesian3(options.radius, options.radius, options.radius)

    this._style = {
      ...options
    }
    this.delegate = new Cesium.Entity({ ellipsoid: {} })
    this._type = 'ellipsoid'
    this.mounted()
  }

  /**
  * 初始化对象属性
  */

  mounted() {
    this.style = this._style
    this.positions = this._positions
    this.radius = this._radius
  }

  /** 
  * @param {*} style Ellipsoid的样式
  * @returns 
  */

  setStyle(style) {
    if (!style) return
    Object.assign(this._style, { ...style })
    Object.assign(this.delegate.ellipsoid, { ...this._style })
  }

  get style(){
    return this._style
  }

  set style(val){
    Object.assign(this._style , {...val})
    Object.assign(this.delegate.ellipsoid , {...this._style})
  }


  get radius() {
    return this._radius
  }

  set radius(val) {
    this._radius = val
    this.delegate.ellipsoid.radii = this._radius
  }

  get positions() {
    return this._positions
  }

  set positions(val) {
    this._positions = val
    this.delegate.position = this._positions
  }
}
